package com.autumn.xa.a.demo.collectiona;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 项目名称：com.autumn.xa
 * 类 名 称：DemoCollection
 * 类 描 述：TODO
 * 创建时间：2021/8/24 9:40 下午
 * 创 建 人：yeachrom
 */
public class DemoCollection {


    public static void main(String[] args) {
        List<String> list1 = new ArrayList<String>();

        list1.add("WQY");
        list1.add("WQY1");

        Collection<String> list2 = Collections.unmodifiableCollection(list1);

        System.out.println("---------list1---------");
        System.out.println(list1.getClass());
        list1.forEach(v -> {
            System.out.println(v);
        });
        System.out.println("---------list1--add-------");
        list1.add("ZWJ2");
        list1.forEach(v ->{
            System.out.println(v);
        });
        System.out.println("---------list2---------");
        System.out.println(list2.getClass());
        list2.forEach(v -> {
            System.out.println(v);
        });
        System.out.println("---------list2--add-------");
        list2.add("ZWJ2");
        list2.forEach(v ->{
            System.out.println(v);
        });

    }
}
